package org.example.service.impl;

import org.example.service.TestService;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Component
public class TestServiceImpl implements TestService {


    //隔离级别设置isolation，推荐Isolation.READ_COMMITTED
    @Override
    @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)//默认readOnly=false//
    // noRollbackFor = IOException.class//指定哪种异常不会回滚
    //timeout=3,设置超时时间3s
    public void add(int a,int b){
        System.out.println(a+b);
    }


}
